package concurrent;

import java.util.concurrent.*;

public class Concurrent {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CountDownLatch downLatch = new CountDownLatch(2);
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        FutureTask task = new FutureTask(()->{
            System.out.println(789);
            Thread.sleep(2000);
            return 0;
        });
        executorService.submit(task);
        System.out.println(234);
        Runnable runnable = () -> System.out.println(123);

        new Thread(runnable).start();

        new Thread(()->{
            System.out.println(456);
        }).start();



        Object o = task.get();
        downLatch.countDown();
        downLatch.countDown();

        downLatch.await();
        System.out.println(o);
    }



}
